package com.device.android.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.hardware.usb.UsbManager
import com.base.constant.What
import com.im.event.DefaultEvent
import com.im.event.post.postEvent

class UsbDeviceReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent) {
        when (intent.action) {
            // 插入USB设备
            UsbManager.ACTION_USB_DEVICE_ATTACHED -> postEvent(DefaultEvent(What.USB))
            // 拔出USB设备
            UsbManager.ACTION_USB_DEVICE_DETACHED -> postEvent(DefaultEvent(What.USB))
        }
    }
}